package com.yanqu.road.server.cmd.activity.turtle;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.TurtleProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.turtle.TurtleModule;
import com.yanqu.road.server.protocol.ClientProtocol;
import com.yanqu.road.server.protocol.Protocol;

/**
 * @Author : Cxp
 * @Time : 2024-09-09
 * @Description : 乌龟对对碰-获取公告信息
 */

@Cmd(code = Protocol.S_TURTLE_GET_NOTICE, desc = "获取公告信息")
public class TurtleGetNoticeCmd extends AbstractCommand {

    private TurtleProto.TurtleNoticeMsgReq reqMsg;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = TurtleProto.TurtleNoticeMsgReq.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        ret = player.getModule(TurtleModule.class).getNotice(reqMsg);
    }

    @Override
    public void sendData(GamePlayer player) {
        if (ret != 0) {
            TurtleProto.TurtleNoticeMsgResp.Builder respMsg = TurtleProto.TurtleNoticeMsgResp.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(ClientProtocol.U_TURTLE_GET_NOTICE, respMsg);
        }
    }
}
